/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.fd.service.impl;

import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xy.lang.domain.Result;
import com.xy.biz.fd.domain.bo.DocumentCodePoolBO;
import com.xy.biz.fd.domain.query.DocumentCodePoolQuery;
import com.xy.biz.fd.service.DocumentCodePoolService;
import com.xy.biz.fd.manager.DocumentCodePoolManager;

/**
 *
 *
 * @author zgy
 * @date 2021-6-11
 */
@Service
public class DocumentCodePoolServiceImpl implements DocumentCodePoolService {

	@Autowired
	private DocumentCodePoolManager documentCodePoolManager;

	@Override
	public Result<? extends Integer> saveDocumentCodePool(DocumentCodePoolBO documentCodePoolBO) {
		int affectedRows = documentCodePoolManager.saveDocumentCodePool(documentCodePoolBO);
		if (affectedRows > 0) {
			return Result.success(affectedRows);
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<?> saveAllDocumentCodePool(Collection<DocumentCodePoolBO> collection) {
		int affectedRows = documentCodePoolManager.saveAllDocumentCodePool(collection);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<? extends Integer> updateDocumentCodePool(DocumentCodePoolBO documentCodePoolBO) {
		int affectedRows = documentCodePoolManager.updateDocumentCodePoolByBO(documentCodePoolBO);
		if (affectedRows > 0) {
			return Result.success(affectedRows);
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<? extends Integer> updateAllDocumentCodePoolByCode(Collection<DocumentCodePoolBO> collection) {
		int affectedRows = documentCodePoolManager.updateAllDocumentCodePoolByCode(collection);
		if (affectedRows > 0) {
			return Result.success(affectedRows);
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<?> deleteDocumentCodePool(Long documentCodePoolId) {
		int affectedRows = documentCodePoolManager.deleteDocumentCodePool(documentCodePoolId);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public DocumentCodePoolBO getDocumentCodePool(Long documentCodePoolId) {
		return documentCodePoolManager.getDocumentCodePool(documentCodePoolId);
	}

	@Override
	public List<DocumentCodePoolBO> listDocumentCodePoolById(Collection<Long> collection) {
		return documentCodePoolManager.listDocumentCodePoolById(collection);
	}

	@Override
	public List<DocumentCodePoolBO> listDocumentCodePool(DocumentCodePoolQuery query) {
		return documentCodePoolManager.listDocumentCodePool(query);
	}

	@Override
	public int countDocumentCodePool(DocumentCodePoolQuery query) {
		return documentCodePoolManager.countDocumentCodePool(query);
	}

}
